home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0019_VOL-SER2.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  64 lines

  1. {
  2. >Who can give me the source code in TP 6.0 which reads a HardDisks Volume
  3. >Serial Number ?
  4.  
  5. Starting With Dos 4 this inFormation can be GET/SET using inT 21h func 69h
  6.    Entry  AH =69h
  7.             Al = 00h    Get Serial number and Label
  8.             Al = 01h    Set Serial number
  9.             BL = drive number 0=default, 1=A: .....)
  10.             DS:DX Pointer to a 24 Bytes  Buffer (see below)
  11.    Return
  12.          Cf set on error
  13.              AX = error code  (same as Int 21h AH = 59 )
  14.          CF Clear if Ok
  15.              if AL was 0 then Buffer is filled with
  16.                 offset   size   Contents:
  17.                 0         Word     0
  18.                 2         DWord    the disk Serial number
  19.                 6         11 Bytes= volume Label or "NO NAME"
  20.                 16        8 Bytes = 'FAT12' or 'FAT16'
  21.  
  22.  The buffer is actually a copy of ByteS $27 to $3D of the Sector 0 of the disk
  23.  So With previous versions of Dos one should be able to do an Absolute read
  24.  of sector 0 from the disk and extract the Info from a buffer. I did not dare
  25.  doing it....
  26.  
  27.  Last Thought: With Dos earlier than 4 , there was no disk serial number
  28.                so what the point looking For one .... !!!!
  29.                Although this info can be used to set one ???
  30.                (not by me... I need too badly my hard disk to
  31.                experiment With Int 13h ..... )
  32.  
  33.   Here is a Program that Get these Infos...
  34.   I did not dare trying the Set Function (AL=1...) see above...
  35. }
  36. Program GetSerial;
  37. Uses
  38.   Dos;
  39. Var
  40.   Buffer : Array[0..23] of Byte;
  41.   R      : Registers;
  42.   Serial : LongInt;
  43.   VLabel : String[11];
  44.   Fat    : String[8];
  45. begin
  46.   R.AH := $69;
  47.   R.AL := 0;
  48.   R.BL := 3;            { C: Drive }
  49.   R.DS := Seg(Buffer);
  50.   R.DX := ofs(Buffer);
  51.   Intr($21,R);
  52.   if (R.Flags and Fcarry = 0) then
  53.   begin
  54.     Move(Buffer[2], Serial, Sizeof(LongInt));
  55.     Move(Buffer[6], VLabel[1], 11);
  56.     VLabel[0] := Char(11);
  57.     Move(Buffer[16], Fat[1], 8);
  58.     Fat[0] := Char(8);
  59.   end;
  60.   Writeln(VLabel);
  61.   Writeln(Fat);
  62.   readln;
  63. end.
  64.